/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package chatserver;

import java.net.ServerSocket;

public class Main {
    public static void main(String[] args) throws Exception {
        
        ChatServer chat = new ChatServer(ChatServer.PORT_ACCOUNT);
        ServerSocket listener = chat.getServerSocket();
        
        System.out.println("Server is Running");
        
        try {
            while (true) {        
                (chat.new ChatAccount(listener.accept())).start();
            }
        } finally {
            listener.close();
        }
        
        /*
        ServerSocket listener = new ServerSocket(ChatServer.PORT);
        System.out.println("Server is Running");
        try {
            while (true) {
                ChatServer chat = new ChatServer();
                ChatServer.ChatConversation client1 = chat.new ChatConversation(listener.accept());
                ChatServer.ChatConversation client2 = chat.new ChatConversation(listener.accept());
                client1.setPartner(client2);
                client2.setPartner(client1);
                client1.start();
                client2.start();
                
                System.out.println("Enjoy with your partner!!!");
            }
        } finally {
            listener.close();
        }*/
    }
}